package com.jie.jie.svg;

import android.graphics.Path;
import android.graphics.drawable.AnimatedVectorDrawable;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v7.app.AppCompatActivity;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.jie.jie.R;
import com.mcxtzhang.pathanimlib.PathAnimView;

import java.text.ParseException;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class SVGActivity extends AppCompatActivity {

    @Bind(R.id.activity_svg)
    LinearLayout activitySvg;
    @Bind(R.id.iv)
    ImageView iv;
    @Bind(R.id.path2)
    PathAnimView path2;
    private Path path;

    @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_svg);
        ButterKnife.bind(this);
        PathUtils utils = new PathUtils();
        AnimatedVectorDrawable animatedVectorDrawable =
                (AnimatedVectorDrawable) iv.getDrawable();
        if(animatedVectorDrawable.isRunning()) {
            animatedVectorDrawable.stop();
        } else {
            animatedVectorDrawable.start();
        }
        try {
            path = utils.parsePath(GAStudioPath.xiaoren);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        path2.setColorFg(0xffFF7700);
        path2.setSourcePath(path);
        path2.startAnim();

    }

    @OnClick(R.id.iv)
    public void onClick() {
    }
}
